package com.silence.thread.gift;

import jdk.nashorn.internal.ir.WhileNode;

import java.util.LinkedList;
import java.util.List;

public class MyThread_gift extends Thread {
    private LinkedList<String> list;
    private int sum;

    public MyThread_gift(LinkedList<String> list, String name) {
        super(name);
        this.list = list;
    }

    @Override
    public void run() {
        while (true) {
            if (list.size() <= 10){
                break;
            }
            String now_gift = list.removeLast();
            System.out.println(Thread.currentThread().getName() + "发出了:" + now_gift);
            sum++;
        }
    }
    public int getSum() {
        return sum;
    }
    public void setSum(int sum) {
        this.sum = sum;
    }
}
